﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Intrack
{
    public partial class os : System.Web.UI.Page
    {
        private void Iniciar()
        {
           MultiView1.SetActiveView(View1);
            GridView1.DataSource = new BLLOS().Listar();
            GridView1.DataBind();


            DropDownList1.DataSource = new BLLCliente().Listar();
            DropDownList1.DataTextField = "Nome";
            DropDownList1.DataValueField = "idCliente";
            DropDownList1.DataBind();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Iniciar();
            }
        }

        protected void btnNovaOs_Click(object sender, EventArgs e)
        {
            MultiView1.SetActiveView(View2);
        }

        protected void btnGravar_Click(object sender, EventArgs e)
        {
            tbOS oOS = new tbOS()
                           {
                               Cod = TextBox1.Text,
                               idCliente = int.Parse(DropDownList1.SelectedValue)
                           };


            BLLOS bllos = new BLLOS();
            bllos.Salvar(oOS);

            GridView1.DataSource = new BLLOS().Listar();
            GridView1.DataBind();

            MultiView1.SetActiveView(View1);
        }

        
    }
}